import { Login } from "@/api/interface/index";
import { PORT } from "@/api/config/servicePort";
import http from "@/api";
import { UnwrapRef } from "vue";

/**
 * @name 登录模块
 */
// 用户登录
export const loginApi = (params: {
  loginPwd: string | number[];
  userName: UnwrapRef<Login.ReqLoginForm["userName"]>;
  verificationCode: UnwrapRef<Login.ReqLoginForm["verificationCode"]>;
  verificationCodeKey: UnwrapRef<Login.ReqLoginForm["verificationCodeKey"]>;
}) => {
  return http.post<string>(PORT + `/system/login`, params, { noLoading: true });
};

export const verifyCodeApi = () => {
  return http.get<Login.VerifyCode>(PORT + `/system/verify/code`, {}, { noLoading: true });
};

export const loginUserApi = () => {
  return http.get<Login.UserInfo>(PORT + `/system/login/user`, {}, { noLoading: true });
};

// 获取菜单列表
export const getUserRouterListApi = () => {
  return http.get<Login.RouterInfo>(PORT + `/system/user/router/list`, {}, { noLoading: true });
};

// 用户退出登录
export const logoutApi = () => {
  return http.post(PORT + `/logout`);
};
